 package client;

 import com.alibaba.druid.pool.DruidPooledConnection;
 import database.DatabaseConnection;
 import java.io.Serializable;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;









 public class MaplePvpStats
   implements Serializable
 {
   private static final long serialVersionUID = -639523813413728519L;
   private int watk;
   private int matk;
   private int wdef;
   private int mdef;
   private int acc;
   private int avoid;
   private int wdef_rate;
   private int mdef_rate;
   private int ignore_def;
   private int damage_rate;
   private int ignore_damage;

   public MaplePvpStats() {}

   public MaplePvpStats(int watk, int matk, int wdef, int mdef, int acc, int avoid, int wdef_rate, int mdef_rate, int ignore_def, int damage_rate, int ignore_damage) {
/*  37 */     this.watk = watk;
/*  38 */     this.matk = matk;
/*  39 */     this.wdef = wdef;
/*  40 */     this.mdef = mdef;
/*  41 */     this.acc = acc;
/*  42 */     this.avoid = avoid;
/*  43 */     this.wdef_rate = wdef_rate;
/*  44 */     this.mdef_rate = mdef_rate;
/*  45 */     this.ignore_def = ignore_def;
/*  46 */     this.damage_rate = damage_rate;
/*  47 */     this.ignore_damage = ignore_damage;
   }

   public static MaplePvpStats loadOrCreateFromDB(int accountId) {
/*  51 */     MaplePvpStats ret = null;
/*  52 */     try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
/*  53 */       PreparedStatement ps = con.prepareStatement("SELECT * FROM pvpstats WHERE accountid = ?");
/*  54 */       ps.setInt(1, accountId);
/*  55 */       ResultSet rs = ps.executeQuery();
/*  56 */       if (rs.next()) {
/*  57 */         ret = new MaplePvpStats(rs.getInt("watk"), rs.getInt("matk"), rs.getInt("wdef"), rs.getInt("mdef"), rs.getInt("acc"), rs.getInt("avoid"), rs.getInt("wdef_rate"), rs.getInt("mdef_rate"), rs.getInt("ignore_def"), rs.getInt("damage_rate"), rs.getInt("ignore_damage"));
       } else {
/*  59 */         PreparedStatement psu = con.prepareStatement("INSERT INTO pvpstats (accountid, watk, matk, wdef, mdef, acc, avoid, wdef_rate, mdef_rate, ignore_def, damage_rate, ignore_damage) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
/*  60 */         psu.setInt(1, accountId);
/*  61 */         psu.setInt(2, 0);
/*  62 */         psu.setInt(3, 0);
/*  63 */         psu.setInt(4, 0);
/*  64 */         psu.setInt(5, 0);
/*  65 */         psu.setInt(6, 100);
/*  66 */         psu.setInt(7, 0);
/*  67 */         psu.setInt(8, 0);
/*  68 */         psu.setInt(9, 0);
/*  69 */         psu.setInt(10, 0);
/*  70 */         psu.setInt(11, 0);
/*  71 */         psu.setInt(12, 0);
/*  72 */         psu.executeUpdate();
/*  73 */         psu.close();
/*  74 */         ret = new MaplePvpStats(0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0);
       }
/*  76 */       rs.close();
/*  77 */       ps.close();
/*  78 */     } catch (SQLException ex) {
/*  79 */       System.err.println("加载角色 Pvp 属性出现错误." + ex);
     }
/*  81 */     return ret;
   }

   public void saveToDb(DruidPooledConnection con, int accountId) {
     try {
/*  86 */       PreparedStatement ps = con.prepareStatement("UPDATE pvpstats SET watk = ?, matk = ?, wdef = ?, mdef = ?, acc = ?, avoid = ?, wdef_rate = ?, mdef_rate = ?, ignore_def = ?, damage_rate = ?, ignore_damage = ? WHERE accountId = ?");
/*  87 */       ps.setInt(1, accountId);
/*  88 */       ps.setInt(2, this.watk);
/*  89 */       ps.setInt(3, this.matk);
/*  90 */       ps.setInt(4, this.wdef);
/*  91 */       ps.setInt(5, this.mdef);
/*  92 */       ps.setInt(6, this.acc);
/*  93 */       ps.setInt(7, this.avoid);
/*  94 */       ps.setInt(8, this.wdef_rate);
/*  95 */       ps.setInt(9, this.mdef_rate);
/*  96 */       ps.setInt(10, this.ignore_def);
/*  97 */       ps.setInt(11, this.damage_rate);
/*  98 */       ps.setInt(12, this.ignore_damage);
/*  99 */       ps.executeUpdate();
/* 100 */       ps.close();
/* 101 */     } catch (SQLException ex) {
/* 102 */       System.err.println("保存角色 Pvp 属性出现错误." + ex);
     }
   }




   public int getWatk() {
/* 110 */     return this.watk;
   }

   public void setWatk(int gain) {
/* 114 */     this.watk = gain;
   }

   public void gainWatk(int gain) {
/* 118 */     this.watk += gain;
   }




   public int getMatk() {
/* 125 */     return this.matk;
   }

   public void setMatk(int gain) {
/* 129 */     this.matk = gain;
   }

   public void gainMatk(int gain) {
/* 133 */     this.matk += gain;
   }




   public int getWdef() {
/* 140 */     return this.wdef;
   }

   public void setWdef(int gain) {
/* 144 */     this.wdef = gain;
   }

   public void gainWdef(int gain) {
/* 148 */     this.wdef += gain;
   }




   public int getMdef() {
/* 155 */     return this.mdef;
   }

   public void setMdef(int gain) {
/* 159 */     this.mdef = gain;
   }

   public void gainMdef(int gain) {
/* 163 */     this.mdef += gain;
   }




   public int getAcc() {
/* 170 */     return this.acc;
   }

   public void setAcc(int gain) {
/* 174 */     this.acc = gain;
   }

   public void gainAcc(int gain) {
/* 178 */     this.acc += gain;
   }




   public int getAvoid() {
/* 185 */     return this.avoid;
   }

   public void setAvoid(int gain) {
/* 189 */     this.avoid = gain;
   }

   public void gainAvoid(int gain) {
/* 193 */     this.avoid += gain;
   }




   public int getWdefRate() {
/* 200 */     return this.wdef_rate;
   }

   public void setWdefRate(int gain) {
/* 204 */     this.wdef_rate = gain;
   }

   public void gainWdefRate(int gain) {
/* 208 */     this.wdef_rate += gain;
   }




   public int getMdefRate() {
/* 215 */     return this.mdef_rate;
   }

   public void setMdefRate(int gain) {
/* 219 */     this.mdef_rate = gain;
   }

   public void gainMdefRate(int gain) {
/* 223 */     this.mdef_rate += gain;
   }




   public int getIgnoreDef() {
/* 230 */     return this.ignore_def;
   }

   public void setIgnoreDef(int gain) {
/* 234 */     this.ignore_def = gain;
   }

   public void gainIgnoreDef(int gain) {
/* 238 */     this.ignore_def += gain;
   }




   public int getDamageRate() {
/* 245 */     return this.damage_rate;
   }

   public void setDamageRate(int gain) {
/* 249 */     this.damage_rate = gain;
   }

   public void gainDamageRate(int gain) {
/* 253 */     this.damage_rate += gain;
   }




   public int getIgnoreDamage() {
/* 260 */     return this.ignore_damage;
   }

   public void setIgnoreDamage(int gain) {
/* 264 */     this.ignore_damage = gain;
   }

   public void gainIgnoreDamage(int gain) {
/* 268 */     this.ignore_damage += gain;
   }
 }


/* Location:              C:\PGX\Server.jar!\client\MaplePvpStats.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */